/** 
* @Title: DemoTest.java
* @Package: org.renne.bankValidation
* @Description: TODO(银行卡验证测试类)
* @author:kevin
* @date:2017年8月4日 上午10:23:34
* @version:V1.0 
*/
package cardval;




import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;
import org.junit.Test;

import utils.HttpPostMap;
import utils.MD5;




public class CardvalTest {
	private static final Logger logger = Logger.getLogger(CardvalTest.class);
	//测试的地址	
	private static final String SERVER_URL = "http://139.196.19.100:8080/cardval/validationCard";
	
	private static final String partnerCode = "12345";//合作商编号
	private static final String PKEY = "d58f37c85f8c4e9c864753917fad2789";//分配商户的key
	private static final String cardNo = "6226590007919322";
	private static final String serialNo = "64519013";
	@Test
	public void test() throws Exception, Exception{
		Map<String, String> params = new HashMap<String, String>();
		//这里与接口文档不一致的
		params.put("PARTNERNO", partnerCode);
		params.put("CARDNO", cardNo);
		params.put("PKEY", PKEY);
		params.put("CARDNAME", "赖志勇");//姓名
		params.put("CARDMOBILE", "13989622058");//手机号
        params.put("CARDIDTYPE", "01");
        params.put("CARDIDCARD", "331022198308302413");//身份证号码
        params.put("SERIALNO",serialNo);
        //这里接口文档的后面几个参数是要调过来的
        String txt = PKEY + "|" + partnerCode + "|" + serialNo + "|" + cardNo + "|"
                + params.get("CARDMOBILE") + "|" + params.get("CARDIDCARD") + "|" + params.get("CARDNAME") + "|" + params.get("CARDIDTYPE");
        params.put("SIGN", MD5.encode(txt));
        System.out.println(params.get("SIGN"));
        String ret = HttpPostMap.post(SERVER_URL, params,1);//Http Post发送
        System.out.println(ret);//{"money":450,"code":"00","desc":"交易成功"}   返回code为00表示成功  非00表示验证失败  money表示合作商剩余金额

	
	}

}
